/*
  Print out a listing of valid commands.
  Variables:
    char *msg - String that is printed to specify why a command failed.
*/
extern void usage(char *msg);

/*
  Put a file onto memcached servers in the ErasureCached format.
  Variables:
    char *filename - String of the complete or relative path to the file that
                     will be stored on the memcached servers.
  Return:
    0 on success, 1 on failure.
*/
extern int put(char *filename);

/*
  Get a file from memcached servers that is in ErasureCached format.
  Variables:
    char *filename - String of the complete or relative path to the .ec file
                     that contains the information necessary to recover a file.
  Return:
    0 on success, 1 on failure.
*/
extern int get(char *filename);

/*
  Touch the time stamp for all blocks on the memcached servers for a particular
  .ec file. Should inform the user if any of the blocks were missing. Possibly
  update the .ec with that information.
  Variables:
    char *filename - String of the complete or relative path to the .ec file
                     that contains the information necessary to touch blocks.
  Return:
    0 on success, 1 on failure.
*/
extern void touch(char *filename);

/*
  Removes all the blocks from the memcached servers associated with a particular
  .ec file.
  Variables:
    char *filename - String of the complete of relative path to the .ec file
                     that contains the information necessary to remove blocks.
  Return:
    0 on success, 1 on failure.
*/
extern void rm(char *filename);

/*
  Encrypts a chunk of data on a random key and encrypts. Then hashes the data
  and XOR's it with the key. This is called the canary. The canary is then
  put on the end of the file.
  Variables:
    char *data - Pointer to the data that will be encrypted.
    long size - Size in bytes of the data pointed to by char *data. There
      should be 16 bytes after for the canary.
  Return:
    0 on success
    1 on failure
*/
extern int encrypt(char *data, unsigned long size);

/*
  Erasure Codes a chunk of data.
  Variables:
    TBA
*/
extern char **encode(char *data, unsigned long size, char **data_ptrs);

/*
  Upload a block to a memcached server.
  Variables:
    char *data - Pointer to the data that will be uploaded.
    long size - Size in bytes of the data pointed to by char *data.
    char *server - Name of the memcached server that the data will be put on.
  Return:
    The key that the data was keyed on the memcached server which is also the
      hash of the block.
	  NULL on failure.
*/
extern char *upload(char *data, unsigned long size, char *server);

//recovers a file from K number of erasure coded blocks
extern char *decode(unsigned long size, char **data_ptrs, int *erased);

/*
  Download a block from a memcached server.
  Variables:
    long size - Size in bytes of the data that will be downloaded.
    char *server - Name of the memcached server that the data will be
                   retrieved from.
    char *key - The key that the data is keyed on memcached.
  Return:
	  Pointer to the data on success
	  NULL on failure
*/
extern char *download(unsigned long size, char *server, char *key);

/*
  Decrypt data in our erasurecached format. Decrypt gets the key from the
  canary on the end of the file.
  Variables:
    char *data - pointer to the data that will be decrypted.
    unsigned long size - size of the data that will be decrypted. This does
      not include the canary.
  Return:
    0 on success
    1 on failure
*/
extern int decrypt(char *data, unsigned long size);
